package com.example.mqtt.service;

import com.example.mqtt.model.DataEntry;
import com.example.mqtt.repository.DataRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class DataService {

    private final DataRepository dataRepository;

    public List<DataEntry> getData() {
        return dataRepository.findAll(Sort.by(Sort.Direction.DESC, "createdAt"));
    }
}